home *** CD-ROM | disk | FTP | other *** search
/ Freelog 15 / FREELOG 15.ISO / WebMaster / Perl / PERL5106.ZIP / perl5 / INSTALL.BAT next >
Encoding:
DOS Batch File  |  1996-01-31  |  5.9 KB  |  215 lines

  1. @rem = '--*-Perl-*--';
  2. @rem = '
  3. @echo off
  4. if not exist ntt\perl.exe goto perlnotthere
  5. echo ntt\perl.exe exists, copying into current directory
  6. del  perl.exe
  7. copy ntt\perl.exe .
  8. if not exist ntt\perl100.dll goto perlnotthere
  9. del  perl100.dll
  10. copy ntt\perl100.dll .
  11. :perldllnotthere
  12. :perlnotthere
  13. if exist perl.exe goto perlhere
  14. echo Could not find Perl interpreter!!
  15. echo *gasp* *wheez* *choke*
  16. pause
  17. goto endofperl 
  18. :perlhere
  19. if exist perl100.dll goto perldllhere
  20. echo Could not find Perl100.dll
  21. echo *gasp* *wheez* *choke*
  22. pause
  23. goto endofperl
  24. :perldllhere
  25. perl %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
  26. goto endofperl
  27. @rem ';
  28.  
  29. BEGIN{
  30. @INC = qw( Lib 
  31.     Ext );
  32.  
  33. };
  34.  
  35. require "NT.ph";
  36.  
  37.  
  38. #(c) 1995 Microsoft Corporation. All rights reserved. 
  39. #        Developed by hip communications inc., http://info.hip.com/info/
  40.  
  41. print <<'--end--';
  42. This install script assumes that you have unpacked 
  43. Perl for Win32 into the final intended destination 
  44. directory. It will copy the executable and batch files
  45. into a separate directory, but all documentation and 
  46. libraries remain where they currently are. 
  47. Do you wish to proceed? [Y/n]
  48. --end--
  49. $in = <STDIN>;
  50. until ( $in eq "\n" || $in =~ /^y/i ) {
  51.     exit if ( $in =~ /^no?\n$/i );
  52.     print "Do you wish to proceed? [Y/n]";
  53.     $in = <STDIN>;
  54. }
  55.  
  56.  
  57. chop( $perldir = `cd` );
  58.  
  59. $libdir = $perldir . '\lib';
  60. $docdir = $perldir . '\docs';
  61.  
  62. $perldir =~ s/\\5\.001//;
  63. $bindir = $perldir . '\bin';
  64.  
  65. require 'ctime.pl' || warn "$!\nDid you preserve the directory structure when you unzipped?\n";
  66.  
  67. $date = ctime( time );
  68.  
  69. if( Win32::IsWinNT() ){
  70.     ( $myversion ) = grep( /perl[^\d]*(\d\.\d\.?\d\.?\d)/, `perl -v` );
  71.     ( $myversion ) = $myversion =~ /perl[^\d]*(\d\.(\d\.?)+)/;
  72. }
  73. else{
  74.     $myversion=95;
  75.     }
  76.     
  77.  
  78. open ( LOG, '>>install.log' ) || warn "Couldn't open log file!\n";
  79.  
  80. &log( $date );
  81.  
  82. sub log {
  83.     ( $message ) = @_;
  84.     print LOG $message;
  85.     print $message;
  86. }
  87.  
  88. sub gripe {
  89.     ( $message ) = @_;
  90.     print LOG $message;
  91.     warn $message;
  92. }
  93.  
  94. if ( -d $bindir ) {
  95.     &log( "$bindir exists\n" );
  96. } else {
  97.     &log( "creating $bindir\n" );
  98.     mkdir( $bindir, 0 ) || die $!;
  99. }
  100.  
  101. &log( "Installing Windows Perl for Win32 into $perldir\n" );
  102.  
  103.  
  104.  
  105. if ( -f "$bindir\\perl.exe" ) {
  106.     if( Win32::IsWinNT() ){
  107.         ( $version ) = grep( /perl[^\d]*(\d\.\d\.?\d\.?\d)/, `$bindir\\perl -v` );    
  108.         ( $version ) = $version =~ /perl[^\d]*(\d\.(\d\.?)+)/;
  109.     }
  110.     else{
  111.         $version = 95;
  112.     }
  113.  
  114.     &log( "Previous version $version exists in bin directory,\n" );
  115.     &log( "Renaming it to perl.$version.exe\n" );
  116.     rename "$bindir\\perl.exe", "$bindir\\perl.$version.exe";
  117. }
  118.  
  119. if ( -f "$bindir\\perl100.dll"){
  120.     $version=$version?$version:"old";                
  121.     &log("Renaming perl100.dll to perl100.$version.dll\n");
  122.     rename "$bindir\\perl100.dll","$bindir\\perl100.$version.dll";
  123. }
  124.  
  125.  
  126. &log("Copying over perl100.dll to $bindir \n");
  127. `copy ntt\\perl100.dll $bindir\\perl100.dll`;
  128.  
  129.  
  130. &log( "Copying over perl and utility scripts to $bindir\n" );
  131.  
  132. `copy ntt\\perl.exe $bindir`;
  133. `copy ntt\\perlglob.exe $bindir`;
  134. `copy ntt\\cmd32.exe $bindir`;
  135. `copy pl2bat.bat $bindir`;
  136.  
  137.  
  138. NTRegCreateKeyEx( &HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Resource Kit\PERL5',
  139.     &NULL, 'NT Perl 5', ®_OPTION_NON_VOLATILE, &KEY_ALL_ACCESS, &NULL,
  140.     $hkey, $disposition ) ?
  141.     &log( "Added key for Perl 5 to NT Registry Database..\n" ):
  142.     &gripe( "Couldn't add key for Perl 5 to NT Registry Database!!\n" );
  143.  
  144. if ( $disposition  == ®_OPENED_EXISTING_KEY ) {
  145.     &gripe( "Key exists already, modifying existing key...\n" );
  146. }
  147.  
  148. NTRegSetValueEx( $hkey, 'BIN', &NULL, ®_SZ, "$bindir" ) ?
  149.     &log( "Adding $bindir to script path information\n" ):
  150.     &gripe( "Couldn't add script path to registry!!\n" );
  151.  
  152. NTRegSetValueEx( $hkey, 'PRIVLIB', &NULL, ®_SZ, "$libdir" ) ?
  153.     &log( "Adding $libdir to library include path information\n" ):
  154.     &gripe( "Couldn't add library path to registry!!\n" );
  155.  
  156. NTRegSetValueEx( $hkey, 'HTML-DOCS', &NULL, ®_SZ, "$docdir" ) ?
  157.     &log( "Adding $docdir to documentation directory\n" ) :
  158.     &gripe( "Couldn't add documentation directory to registry!!\n" );
  159.  
  160. NTRegCloseKey( $hkey );
  161.  
  162. $fred = 'foo bar baz';
  163.  
  164. until ( $fred =~ /^(y|n)/i || $fred eq '' ) {
  165.     print "Modify search path? [Y/n]";
  166.     chop( $fred = <STDIN> );
  167. }
  168.  
  169. unless ( $fred =~ /^n/i ) {
  170.         if( Win32::IsWinNT() ){
  171.             NTRegOpenKeyEx ( &HKEY_LOCAL_MACHINE,
  172.                 'SYSTEM\CurrentcontrolSet\control\Session Manager\Environment',
  173.                 &NULL, &KEY_ALL_ACCESS, $hkey ) ?
  174.                 &log( "Retrieving Path information from session manager\n" ):
  175.                 &gripe( "Couldn't retrieve path information from session manager!!\n" );
  176.         
  177.             NTRegQueryValueEx( $hkey, 'Path', &NULL, $type, $pathstring );
  178.         
  179.             $pathstring =
  180.                 ".;$bindir;" . join (';', grep(!/(perl|\.)/i, split(/;/, $pathstring))) . ";";
  181.         
  182.             NTRegSetValueEx( $hkey, 'Path', &NULL, $type, $pathstring ) ?
  183.                 &log( "Updated path information in session manager\n" ):
  184.                 &gripe( "Couldn't update path information in session manager!!\n" );
  185.             NTRegCloseKey( $hkey );
  186.         }
  187.        else{ # must be win95, so update path in autoexec.bat
  188.         
  189.         &log("Attempting to change path in autoexec.bat");
  190.         ( $bootdrive = $ENV{'windir'} ) =~ s|\\.*||g;
  191.         &log( "bootdrive is $bootdrive\n");
  192.  
  193.         open( ABAT,">>$bootdrive\\autoexec.bat")||
  194.                 gripe( "Couldn't open $bootdrive\\autoexec.bat");
  195.  
  196.         print ABAT "path %path%;$bindir;\n";
  197.         close ABAT;
  198.  
  199.        }
  200.  
  201. }
  202.  
  203. &log( "Perl $myversion installation finished.\n" );
  204. print "NOTE: The updated path information will not take effect\n";
  205. if( Win32::IsWinNT() ){
  206.         print "      until you log off and back on again. enjoy ;-)\n";
  207. }
  208. else{
  209.         print "      until you reboot your machine. enjoy ;-)\n";
  210. }
  211.  
  212.  
  213. __END__
  214. :endofperl
  215.